<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />


<meta name="author" content="Yiying Wang" />

<meta name="date" content="2017-03-15" />

<title>Basic Plots 22 - Funnel Chart</title>

<script src="libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="libs/navigation-1.1/tabsets.js"></script>
<script src="libs/htmlwidgets-0.8/htmlwidgets.js"></script>
<script src="libs/echarts-2.2.7/echarts-all.js"></script>
<script src="libs/charts-ext-2.2.7/main.js"></script>
<script src="libs/charts-ext-2.2.7/BMap.js"></script>
<script src="libs/echarts-binding-0.2/echarts.js"></script>


<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
<style type="text/css">
  pre:not([class]) {
    background-color: white;
  }
</style>


<style type="text/css">
h1 {
  font-size: 34px;
}
h1.title {
  font-size: 38px;
}
h2 {
  font-size: 30px;
}
h3 {
  font-size: 24px;
}
h4 {
  font-size: 18px;
}
h5 {
  font-size: 16px;
}
h6 {
  font-size: 12px;
}
.table th:not([align]) {
  text-align: left;
}
</style>

<link rel="stylesheet" href="/home/madlogos/R/x86_64-pc-linux-gnu-library/3.3/knitr/misc/vignette.css" type="text/css" />

</head>

<body>

<style type = "text/css">
.main-container {
  max-width: 940px;
  margin-left: auto;
  margin-right: auto;
}
code {
  color: inherit;
  background-color: rgba(0, 0, 0, 0.04);
}
img {
  max-width:100%;
  height: auto;
}
.tabbed-pane {
  padding-top: 12px;
}
button.code-folding-btn:focus {
  outline: none;
}
</style>



<div class="container-fluid main-container">

<!-- tabsets -->
<script>
$(document).ready(function () {
  window.buildTabsets("TOC");
});
</script>

<!-- code folding -->






<div class="fluid-row" id="header">



<h1 class="title toc-ignore">Basic Plots 22 - Funnel Chart</h1>
<h4 class="author"><em>Yiying Wang</em></h4>
<h4 class="date"><em>2017-03-15</em></h4>

</div>

<div id="TOC">
<ul>
<li><a href="#introduction"><span class="toc-section-number">1</span> Introduction</a></li>
<li><a href="#function-call"><span class="toc-section-number">2</span> Function Call</a></li>
<li><a href="#showcase"><span class="toc-section-number">3</span> Showcase</a><ul>
<li><a href="#data-preparation"><span class="toc-section-number">3.1</span> Data Preparation</a></li>
<li><a href="#funnel-chart"><span class="toc-section-number">3.2</span> Funnel Chart</a><ul>
<li><a href="#single-funnel"><span class="toc-section-number">3.2.1</span> Single Funnel</a></li>
<li><a href="#stacked-funnel"><span class="toc-section-number">3.2.2</span> Stacked Funnel</a></li>
<li><a href="#multiple-funnel"><span class="toc-section-number">3.2.3</span> Multiple Funnel</a></li>
<li><a href="#with-timeline"><span class="toc-section-number">3.2.4</span> With Timeline</a></li>
<li><a href="#different-alignment"><span class="toc-section-number">3.2.5</span> Different Alignment</a></li>
</ul></li>
<li><a href="#pyramid-chart"><span class="toc-section-number">3.3</span> Pyramid Chart</a></li>
</ul></li>
<li><a href="#futher-setup"><span class="toc-section-number">4</span> Futher Setup</a></li>
</ul>
</div>

<p>First, you should load <code>recharts</code>:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(recharts)</code></pre></div>
<div id="introduction" class="section level1">
<h1><span class="header-section-number">1</span> Introduction</h1>
<p>Funnel plot includes 2 basic types:</p>
<ul>
<li>Funnel</li>
<li>Pyramid</li>
</ul>
<table id="intro">
<tr>
<td>
<div id="htmlwidget-fa8432105a9ac30ffbbd" style="width:400px;height:300px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-fa8432105a9ac30ffbbd">{"x":{"series":[{"name":"Proportion","type":"funnel","data":[{"name":"1","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["50%","50%"],"width":"90%","x":"5%","radius":"90%","max":10,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"right","y":"center","orient":"vertical"},"theme":"infographic","title":{"text":"mtcars: carb distibution by am","subtext":"funnel","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</td>
<td>
<div id="htmlwidget-ac5a80467a4bdee04a11" style="width:400px;height:300px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-ac5a80467a4bdee04a11">{"x":{"series":[{"name":"Proportion","type":"funnel","data":[{"name":"1","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["50%","50%"],"width":"90%","x":"5%","radius":"90%","max":10,"height":"70%","y":"15%","selectedMode":"single","sort":"ascending","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"right","y":"center","orient":"vertical"},"theme":"roma","title":{"text":"mtcars: carb distibution by am","subtext":"pyramid","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</td>
</tr>
</table>
<p>The keys are:</p>
<ul>
<li>character <code>x</code> and numeric <code>y</code> and will be compacted using <code>data.table::dcast</code> with <code>fun=sum</code></li>
<li><strong><code>x</code> is used as series, <code>series</code> is used to produce stacked funnels, while <code>facet</code> is used to produce separate funnels!</strong></li>
<li>Pie and funnel charts can shift from one to another by clicking type shift buttons in the toolbox widget.</li>
</ul>
</div>
<div id="function-call" class="section level1">
<h1><span class="header-section-number">2</span> Function Call</h1>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(data, x, &lt;y&gt;, &lt;series&gt;, &lt;facet&gt;, &lt;t&gt;, &lt;type&gt;, &lt;subtype&gt;)</code></pre></div>
<table>
<colgroup>
<col width="11%" />
<col width="88%" />
</colgroup>
<thead>
<tr class="header">
<th>Arg</th>
<th>Requirement</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p><strong>data</strong></p></td>
<td><p>source data in the form of data.frame</p></td>
</tr>
<tr class="even">
<td><p><strong>x</strong></p></td>
<td><p>character independent variable. Each level of <code>x</code> is treated as a data series. Other type will be coerced to factors. Only the first one is accepted if multiple variables are provided.</p></td>
</tr>
<tr class="odd">
<td><p>y</p></td>
<td><p>numeric dependent variable. Only the first one is accepted if multiple variables are provided.</p></td>
</tr>
<tr class="even">
<td><p>series</p></td>
<td><p>series variable which will be coerced to factors. Each level of <code>series</code> is treated as a subsetting factor to produce stacked funnels. Only the first one is accepted if multiple variables are provided.</p></td>
</tr>
<tr class="odd">
<td><p>facet</p></td>
<td><p>facetting variable which will be coerced to factors. Each level of <code>facet</code> is treated as a subsetting factor to produce separate funnels. Only the first one is accepted if multiple variables are provided.</p></td>
</tr>
<tr class="even">
<td><p>t</p></td>
<td><p>timeline variable which will be coerced to factors. Only the first one is accepted if multiple variables are provided.</p></td>
</tr>
<tr class="odd">
<td><p>type</p></td>
<td><p>‘funnel’, ‘pyramid’.</p></td>
</tr>
<tr class="even">
<td><p>subtype</p></td>
<td><ul>
<li>funnel: c(“left”,“center”,“right”)
<ul>
<li>left: funnelAlign left</li>
<li>center: funnelAlign center (default)</li>
<li>right: funnelAlign right</li>
</ul></li>
<li>pyramid: c(“left”,“center”,“right”)
<ul>
<li>left: funnelAlign left</li>
<li>center: funnelAlign center (default)</li>
<li>right: funnelAlign right</li>
</ul></li>
</ul></td>
</tr>
</tbody>
</table>
</div>
<div id="showcase" class="section level1">
<h1><span class="header-section-number">3</span> Showcase</h1>
<div id="data-preparation" class="section level2">
<h2><span class="header-section-number">3.1</span> Data Preparation</h2>
<p>Let’s look into <code>mtcars</code> dataset embeded in the package <code>datasets</code>. The distribution by carb and am is shown as below:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">cars &lt;-<span class="st"> </span>data.table::<span class="kw">dcast</span>(mtcars, carb+am~., length, <span class="dt">value.var=</span><span class="st">&#39;gear&#39;</span>)
<span class="kw">names</span>(cars) &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;carb&quot;</span>, <span class="st">&quot;am&quot;</span>, <span class="st">&quot;N&quot;</span>)
knitr::<span class="kw">kable</span>(cars)</code></pre></div>
<table>
<thead>
<tr class="header">
<th align="right">carb</th>
<th align="right">am</th>
<th align="right">N</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="right">1</td>
<td align="right">0</td>
<td align="right">3</td>
</tr>
<tr class="even">
<td align="right">1</td>
<td align="right">1</td>
<td align="right">4</td>
</tr>
<tr class="odd">
<td align="right">2</td>
<td align="right">0</td>
<td align="right">6</td>
</tr>
<tr class="even">
<td align="right">2</td>
<td align="right">1</td>
<td align="right">4</td>
</tr>
<tr class="odd">
<td align="right">3</td>
<td align="right">0</td>
<td align="right">3</td>
</tr>
<tr class="even">
<td align="right">4</td>
<td align="right">0</td>
<td align="right">7</td>
</tr>
<tr class="odd">
<td align="right">4</td>
<td align="right">1</td>
<td align="right">3</td>
</tr>
<tr class="even">
<td align="right">6</td>
<td align="right">1</td>
<td align="right">1</td>
</tr>
<tr class="odd">
<td align="right">8</td>
<td align="right">1</td>
<td align="right">1</td>
</tr>
</tbody>
</table>
</div>
<div id="funnel-chart" class="section level2">
<h2><span class="header-section-number">3.2</span> Funnel Chart</h2>
<div id="single-funnel" class="section level3">
<h3><span class="header-section-number">3.2.1</span> Single Funnel</h3>
<p><code>type</code> is set ‘funnel’.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">type=</span><span class="st">&#39;funnel&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution&#39;</span>)</code></pre></div>
<div id="htmlwidget-6787fdaa94dc5f4ded83" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-6787fdaa94dc5f4ded83">{"x":{"series":[{"name":"Proportion","type":"funnel","data":[{"name":"1","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":10,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["50%","50%"],"width":"90%","x":"5%","radius":"90%","max":10,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</div>
<div id="stacked-funnel" class="section level3">
<h3><span class="header-section-number">3.2.2</span> Stacked Funnel</h3>
<p>Set <code>series</code> to produce a stacked funnel chart.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, am, <span class="dt">type=</span><span class="st">&#39;funnel&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am&#39;</span>)</code></pre></div>
<div id="htmlwidget-6f7b69e5b19798fda8e6" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-6f7b69e5b19798fda8e6">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["50%","50%"],"width":"90%","x":"5%","radius":"90%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["50%","50%"],"width":"45%","x":"27.5%","radius":"45%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</div>
<div id="multiple-funnel" class="section level3">
<h3><span class="header-section-number">3.2.3</span> Multiple Funnel</h3>
<p>Funnel chart uses <code>facet</code> as subsetting factor to produce seperate polar systems. So when we apply <code>am</code> (containing 2 levels) as <code>facet</code>, we get 2 funnels.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">facet=</span>am, <span class="dt">type=</span><span class="st">&#39;funnel&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am&#39;</span>)</code></pre></div>
<div id="htmlwidget-d836e78e0f2804db8790" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-d836e78e0f2804db8790">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","50%"],"width":"42.5%","x":"6.25%","radius":"42.5%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","50%"],"width":"42.5%","x":"51.25%","radius":"42.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</div>
<div id="with-timeline" class="section level3">
<h3><span class="header-section-number">3.2.4</span> With Timeline</h3>
<p>We need another variable as timeline. Let’s say, ‘gear’.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">cars_gear &lt;-<span class="st"> </span>data.table::<span class="kw">dcast</span>(mtcars, carb+gear+am~., length, <span class="dt">value.var=</span><span class="st">&#39;gear&#39;</span>)
<span class="kw">names</span>(cars_gear) &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;carb&quot;</span>, <span class="st">&quot;gear&quot;</span>, <span class="st">&quot;am&quot;</span>, <span class="st">&quot;N&quot;</span>)</code></pre></div>
<p>In order to make timeline work properly, we need an expand.grid dataset to cover all the combination of <code>x</code> and <code>t</code> levels.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fullData &lt;-<span class="st"> </span><span class="kw">with</span>(mtcars, <span class="kw">data.frame</span>(
    <span class="kw">expand.grid</span>(<span class="kw">unique</span>(carb), <span class="kw">unique</span>(gear), <span class="kw">unique</span>(am))))
<span class="kw">names</span>(fullData) &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;carb&quot;</span>, <span class="st">&quot;gear&quot;</span>, <span class="st">&quot;am&quot;</span>)
cars_gear &lt;-<span class="st"> </span><span class="kw">merge</span>(cars_gear, fullData, <span class="dt">all.y=</span><span class="ot">TRUE</span>)</code></pre></div>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars_gear, carb, N, <span class="dt">facet=</span>am, <span class="dt">t=</span>gear, <span class="dt">type=</span><span class="st">&#39;funnel&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am across gear&#39;</span>)</code></pre></div>
<div id="htmlwidget-0092144ee4c04466701e" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-0092144ee4c04466701e">{"x":{"timeline":{"type":"number","data":[3,4,5],"x":80,"x2":80,"y2":50},"options":[{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":5,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","45%"],"width":"37.5%","x":"8.75%","radius":"37.5%","max":5,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","45%"],"width":"37.5%","x":"53.75%","radius":"37.5%","max":0,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am across gear (gear: 3)","x":"center","y":"bottom","orient":"horizontal"}},{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":2,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":2,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","45%"],"width":"37.5%","x":"8.75%","radius":"37.5%","max":2,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":2,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":2,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","45%"],"width":"37.5%","x":"53.75%","radius":"37.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"title":{"text":"mtcars: carb distibution by am across gear (gear: 4)","x":"center","y":"bottom","orient":"horizontal"}},{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","45%"],"width":"37.5%","x":"8.75%","radius":"37.5%","max":0,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":2,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":"-","itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","45%"],"width":"37.5%","x":"53.75%","radius":"37.5%","max":2,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"title":{"text":"mtcars: carb distibution by am across gear (gear: 5)","x":"center","y":"bottom","orient":"horizontal"}}]},"evals":[],"jsHooks":[]}</script>
</div>
<div id="different-alignment" class="section level3">
<h3><span class="header-section-number">3.2.5</span> Different Alignment</h3>
<p>Left align.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">facet=</span>am, <span class="dt">type=</span><span class="st">&#39;funnel&#39;</span>, <span class="dt">subtype=</span><span class="st">&#39;left&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am across gear&#39;</span>)</code></pre></div>
<div id="htmlwidget-61f63481e9d5d2c65a2a" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-61f63481e9d5d2c65a2a">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","50%"],"width":"42.5%","x":"6.25%","radius":"42.5%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}},"funnelAlign":"left"},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","50%"],"width":"42.5%","x":"51.25%","radius":"42.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}},"funnelAlign":"left"}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am across gear","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<div id="pyramid-chart" class="section level2">
<h2><span class="header-section-number">3.3</span> Pyramid Chart</h2>
<p><code>type</code> is set ‘pyramid’.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">facet=</span>am, <span class="dt">type=</span><span class="st">&#39;pyramid&#39;</span>) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am&#39;</span>)</code></pre></div>
<div id="htmlwidget-cf249054a9807af3581a" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-cf249054a9807af3581a">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","50%"],"width":"42.5%","x":"6.25%","radius":"42.5%","max":7,"height":"70%","y":"15%","selectedMode":"single","sort":"ascending","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","50%"],"width":"42.5%","x":"51.25%","radius":"42.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","sort":"ascending","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
<p>You can also mix <code>funnel</code> and <code>pyramid</code>. Note that you need to wrap <code>type</code> and <code>subtype</code> in list since they are thus associated with <code>facets</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">facet=</span>am, <span class="dt">type=</span><span class="kw">list</span>(<span class="st">&#39;funnel&#39;</span>, <span class="st">&#39;pyramid&#39;</span>)) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am&#39;</span>)</code></pre></div>
<div id="htmlwidget-a38331eb548926ad3fac" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-a38331eb548926ad3fac">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","50%"],"width":"42.5%","x":"6.25%","radius":"42.5%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}}},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","50%"],"width":"42.5%","x":"51.25%","radius":"42.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","sort":"ascending","itemStyle":{"normal":{"labelLine":{"show":true}}}}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">echartr</span>(cars, carb, N, <span class="dt">facet=</span>am, <span class="dt">type=</span><span class="kw">list</span>(<span class="st">&#39;funnel&#39;</span>, <span class="st">&#39;pyramid&#39;</span>), 
        <span class="dt">subtype=</span><span class="kw">list</span>(<span class="st">&#39;right&#39;</span>, <span class="st">&#39;left&#39;</span>)) %&gt;%<span class="st"> </span>
<span class="st">    </span><span class="kw">setTitle</span>(<span class="st">&#39;mtcars: carb distibution by am&#39;</span>)</code></pre></div>
<div id="htmlwidget-9963413aabbd203206bc" style="width:672px;height:480px;" class="echarts html-widget"></div>
<script type="application/json" data-for="htmlwidget-9963413aabbd203206bc">{"x":{"series":[{"name":"0","type":"funnel","data":[{"name":"1","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":6,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":7,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["27.5%","50%"],"width":"42.5%","x":"6.25%","radius":"42.5%","max":7,"height":"70%","y":"15%","selectedMode":"single","itemStyle":{"normal":{"labelLine":{"show":true}}},"funnelAlign":"right"},{"name":"1","type":"funnel","data":[{"name":"1","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"2","value":4,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"3","value":0,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"4","value":3,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"6","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}},{"name":"8","value":1,"itemStyle":{"normal":{"label":{"show":false},"labelLine":{"show":false}}}}],"center":["72.5%","50%"],"width":"42.5%","x":"51.25%","radius":"42.5%","max":4,"height":"70%","y":"15%","selectedMode":"single","sort":"ascending","itemStyle":{"normal":{"labelLine":{"show":true}}},"funnelAlign":"left"}],"xAxis":[{"type":"value","show":false,"position":"bottom","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"yAxis":[{"type":"value","show":false,"position":"left","name":"","nameLocation":"end","boundaryGap":[0,0],"scale":true,"axisLine":{"show":true,"onZero":false},"axisTick":{"show":false},"axisLabel":{"show":true},"splitLine":{"show":true},"splitArea":{"show":false}}],"grid":{"borderWidth":0},"tooltip":{"show":true,"trigger":"item","axisPointer":{"type":"none","crossStyle":{"type":"dashed"},"lineStyle":{"type":"solid","width":1},"shadowStyle":{"color":"rgba(150,150,150,0.3)","width":"auto","type":"default"}},"textStyle":{"color":"#fff"},"islandFormatter":"{a} < br/>{b} : {c}","enterable":false,"showDelay":20,"hideDelay":100,"transitionDuration":0.4,"backgroundColor":"rgba(0,0,0,0.7)","borderColor":"#333","borderWidth":0,"borderRadius":4},"toolbox":{"show":true,"feature":{"mark":{"show":true},"dataZoom":{"show":true},"dataView":{"show":true,"readOnly":false},"magicType":{"show":true,"type":["pie","funnel"]},"restore":{"show":true},"saveAsImage":{"show":true}},"x":"right","y":"top","orient":"horizontal"},"legend":{"show":true,"data":["1","2","3","4","6","8"],"x":"left","y":"top","orient":"horizontal"},"title":{"text":"mtcars: carb distibution by am","x":"center","y":"bottom","orient":"horizontal"}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<div id="futher-setup" class="section level1">
<h1><span class="header-section-number">4</span> Futher Setup</h1>
<p>Then you can configure the widgets, add markLines and/or markPoints, fortify the chart.</p>
<p>You can refer to related functions to play around on your own.</p>
</div>

<script type="text/javascript">
window.onload = function() {
  var i, fig = 1, caps = document.getElementsByClassName('caption');
  for (i = 0; i < caps.length; i++) {
    var cap = caps[i];
    if (cap.parentElement.className !== 'figure' || cap.nodeName !== 'P')
      continue;
    cap.innerHTML = '<span>Figure ' + fig + ':</span> ' + cap.innerHTML;
    fig++;
  }
  fig = 1;
  caps = document.getElementsByTagName('caption');
  for (i = 0; i < caps.length; i++) {
    var cap = caps[i];
    if (cap.parentElement.nodeName !== 'TABLE') continue;
    cap.innerHTML = '<span>Table ' + fig + ':</span> ' + cap.innerHTML;
    fig++;
  }
}
</script>



</div>

<script>

// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
  $('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
  bootstrapStylePandocTables();
});


</script>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>
